#include "bbtest.h"

BbTest::BbTest(QWidget *parent) :
    QWidget(parent)
{
    QFont ft;
    ft.setPixelSize(20);
    wcTestbb = new QLabel(tr("CT变比测试"));
    wcTestbb->setFont(ft);

    ft.setPixelSize(15);
    button1 = new myButton;
    button1->setText(tr("1A变比测试"));
    button1->setFixedSize(180,40);
    button1->setFont(ft);
    button2 = new myButton;
    button2->setText(tr("5A变比测试"));
    button2->setFixedSize(180,40);
    button2->setFont(ft);

    port5 = new QRadioButton(tr("接线在【40A~5A】端子"));
    port5->setFont(ft);
    port5->setChecked(true);
    port50 = new QRadioButton(tr("接线在【400A~50A】端子"));
    port50->setFont(ft);
    port500 = new QRadioButton(tr("接线在【5000A~500A】端子"));
    port500->setFont(ft);

    QHBoxLayout *bbtest = new QHBoxLayout;
    bbtest->addStretch(1);
    bbtest->addWidget(wcTestbb);
    bbtest->addStretch(1);
    QHBoxLayout *bbtest1 = new QHBoxLayout;
    bbtest1->addStretch(1);
    bbtest1->addWidget(button1);
    bbtest1->addStretch(1);
    QHBoxLayout *bbtest2 = new QHBoxLayout;
    bbtest2->addStretch(1);
    bbtest2->addWidget(button2);
    bbtest2->addStretch(1);
    QHBoxLayout *bbtest3 = new QHBoxLayout;
    bbtest3->addSpacing(380);
    bbtest3->addWidget(port5);
    bbtest3->addStretch(1);
    QHBoxLayout *bbtest4 = new QHBoxLayout;
    bbtest4->addSpacing(380);
    bbtest4->addWidget(port50);
    bbtest4->addStretch(1);
    QHBoxLayout *bbtest5 = new QHBoxLayout;
    bbtest5->addSpacing(380);
    bbtest5->addWidget(port500);
    bbtest5->addStretch(1);


    QVBoxLayout *bbmain = new QVBoxLayout;
    //bbmain->addStretch(1);
    bbmain->addLayout(bbtest);
    bbmain->addSpacing(30);
    bbmain->addLayout(bbtest3);
    bbmain->addLayout(bbtest4);
    bbmain->addLayout(bbtest5);
    bbmain->addSpacing(50);
    bbmain->addLayout(bbtest1);
    bbmain->addSpacing(5);
    bbmain->addLayout(bbtest2);
    bbmain->addStretch(1);

    setLayout(bbmain);
    connect(button1,SIGNAL(clicked(QString)),this,SLOT(test_1A()));
    connect(button2,SIGNAL(clicked(QString)),this,SLOT(test_5A()));
}
void BbTest::test_1A()
{
    QFont ft;
    ft.setPixelSize(20);
    qDebug()<<"1a";
    addwidget3=new QWidget;

    addwidget3->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
    addwidget3->setFixedSize(1020,485);
    addwidget3->move(173,196);
    addwidget3->setStyleSheet(".QWidget{background-color:#bbb;}");

    QLabel *bhTest = new QLabel(tr("CT变化测试(1A)"));
    bhTest->setFont(ft);
    QPushButton *close = new QPushButton(tr("关闭"));
    close->setFont(ft);
    close->setStyleSheet("background-color:#bbb");

    ft.setPixelSize(15);

    labbh=new QLabel("--");
    setDataStyle(labbh);
    labsc=new QLabel("--");
    setDataStyle(labsc);
    labjx=new QLabel("--");
    setDataStyle(labjx);

    QLabel *ctBH = new QLabel(tr("CT变化 :"));
    ctBH->setFont(ft);
    QLabel *ctBHx = new QLabel(tr("/1"));
    ctBHx->setFont(ft);
    QLabel *shice  = new QLabel(tr("实测变化 :"));
    shice->setFont(ft);
    QLabel *ctTX = new QLabel(tr("CT极性 :"));
    ctTX->setFont(ft);
    QLabel *bcdw = new QLabel(tr(" f :"));
    bcdw->setFont(ft);
    QLabel *jcdw = new QLabel(tr(" δ :"));
    jcdw->setFont(ft);
    QLabel *bfbdw = new QLabel(tr(" % :"));
    bfbdw->setFont(ft);
    labbc = new QLabel(tr("--"));
    setDataStyle(labbc);
    labjc = new QLabel(tr("--"));
    setDataStyle(labjc);
    labbfb = new QLabel(tr("--"));
    setDataStyle(labbfb);


    QHBoxLayout *bhtest1 = new QHBoxLayout;
    bhtest1->addStretch(1);
    bhtest1->addWidget(bhTest);
    bhtest1->addStretch(1);
    QHBoxLayout *bhtest2 = new QHBoxLayout;
   // bhtest2->addStretch(1);
    bhtest2->addSpacing(350);
    bhtest2->addWidget(ctBH);
    bhtest2->addWidget(labbh);
    bhtest2->addWidget(ctBHx);
    bhtest2->addStretch(1);

    QHBoxLayout *bhtest3 = new QHBoxLayout;
    //bhtest3->addStretch(1);
    bhtest3->addSpacing(340);
    bhtest3->addWidget(shice);
    bhtest3->addWidget(labsc);
    bhtest3->addStretch(1);

    QHBoxLayout *bhtest4 = new QHBoxLayout;
    //bhtest4->addStretch(1);
    bhtest4->addSpacing(350);
    bhtest4->addWidget(ctTX);
    bhtest4->addWidget(labjx);
    bhtest4->addStretch(1);

    QHBoxLayout *bhtest5 = new QHBoxLayout;
    bhtest5->addStretch(1);
    bhtest5->addWidget(close);
    bhtest5->addStretch(1);

    QHBoxLayout *bhtest6 = new QHBoxLayout;
    bhtest6->addStretch(1);
    bhtest6->addWidget(bcdw);
    bhtest6->addWidget(labbc);
    bhtest6->addSpacing(70);
    bhtest6->addWidget(jcdw);
    bhtest6->addWidget(labjc);
    bhtest6->addSpacing(70);
    bhtest6->addWidget(labbfb);
    bhtest6->addWidget(bfbdw);
    bhtest6->addStretch(1);


    QVBoxLayout *btmain = new QVBoxLayout;
    btmain->addSpacing(10);
    btmain->addLayout(bhtest1);
    btmain->addSpacing(30);
    btmain->addLayout(bhtest2);
    btmain->addSpacing(30);
    btmain->addLayout(bhtest3);
    btmain->addSpacing(30);
    btmain->addLayout(bhtest4);
    btmain->addSpacing(50);
    btmain->addLayout(bhtest6);
    btmain->addSpacing(100);
    btmain->addLayout(bhtest5);

    btmain->addStretch(1);

    addwidget3->setLayout(btmain);
    addwidget3->show();

    connect(close,SIGNAL(clicked()),this,SLOT(close_1A()));
}

void BbTest::test_5A()
{
    QFont ft;
    ft.setPixelSize(20);
    qDebug()<<"5a";
    addwidget4=new QWidget;

    addwidget4->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
    addwidget4->setFixedSize(1020,485);
    addwidget4->move(173,196);
    addwidget4->setStyleSheet(".QWidget{background-color:#bbb;}");

    QLabel *bhTest = new QLabel(tr("CT变化测试(5A)"));
    bhTest->setFont(ft);

    QPushButton *close = new QPushButton(tr("关闭"));
    close->setFont(ft);
    close->setStyleSheet("background-color:#bbb");
    ft.setPixelSize(15);

    labbh5=new QLabel("--");
    setDataStyle(labbh);
    labsc5=new QLabel("--");
    setDataStyle(labsc);
    labjx5=new QLabel("--");
    setDataStyle(labjx);

    QLabel *ctBH = new QLabel(tr("CT变化 :"));
    ctBH->setFont(ft);
    QLabel *ctBHx = new QLabel(tr("/5"));
    ctBHx->setFont(ft);
    QLabel *shice  = new QLabel(tr("实测变化 :"));
    shice->setFont(ft);
    QLabel *ctTX = new QLabel(tr("CT极性 :"));
    ctTX->setFont(ft);

    QLabel *bcdw = new QLabel(tr(" f :"));
    bcdw->setFont(ft);
    QLabel *jcdw = new QLabel(tr(" δ :"));
    jcdw->setFont(ft);
    QLabel *bfbdw = new QLabel(tr(" % :"));
    bfbdw->setFont(ft);
    labbc5 = new QLabel(tr("--"));
    setDataStyle(labbc5);
    labjc5 = new QLabel(tr("--"));
    setDataStyle(labjc5);
    labbfb5 = new QLabel(tr("--"));
    setDataStyle(labbfb5);

    QHBoxLayout *bhtest1 = new QHBoxLayout;
    bhtest1->addStretch(1);
    bhtest1->addWidget(bhTest);
    bhtest1->addStretch(1);
    QHBoxLayout *bhtest2 = new QHBoxLayout;
   // bhtest2->addStretch(1);
    bhtest2->addSpacing(350);
    bhtest2->addWidget(ctBH);
    bhtest2->addWidget(labbh);
    bhtest2->addWidget(ctBHx);
    bhtest2->addStretch(1);

    QHBoxLayout *bhtest3 = new QHBoxLayout;
    //bhtest3->addStretch(1);
    bhtest3->addSpacing(340);
    bhtest3->addWidget(shice);
    bhtest3->addWidget(labsc);
    bhtest3->addStretch(1);

    QHBoxLayout *bhtest4 = new QHBoxLayout;
    //bhtest4->addStretch(1);
    bhtest4->addSpacing(350);
    bhtest4->addWidget(ctTX);
    bhtest4->addWidget(labjx);
    bhtest4->addStretch(1);

    QHBoxLayout *bhtest5 = new QHBoxLayout;
    bhtest5->addStretch(1);
    bhtest5->addWidget(close);
    bhtest5->addStretch(1);

    QHBoxLayout *bhtest6 = new QHBoxLayout;
    bhtest6->addStretch(1);
    bhtest6->addWidget(bcdw);
    bhtest6->addWidget(labbc5);
    bhtest6->addSpacing(70);
    bhtest6->addWidget(jcdw);
    bhtest6->addWidget(labjc5);
    bhtest6->addSpacing(70);
    bhtest6->addWidget(labbfb5);
    bhtest6->addWidget(bfbdw);
    bhtest6->addStretch(1);

    QVBoxLayout *btmain = new QVBoxLayout;
    btmain->addSpacing(10);
    btmain->addLayout(bhtest1);
    btmain->addSpacing(30);
    btmain->addLayout(bhtest2);
    btmain->addSpacing(30);
    btmain->addLayout(bhtest3);
    btmain->addSpacing(30);
    btmain->addLayout(bhtest4);
    btmain->addSpacing(50);
    btmain->addLayout(bhtest6);
    btmain->addSpacing(100);
    btmain->addLayout(bhtest5);
    btmain->addStretch(1);
    addwidget4->setLayout(btmain);
    addwidget4->show();
    connect(close,SIGNAL(clicked()),this,SLOT(close_5A()));
}
void BbTest::close_1A()
{
    addwidget3->close();
}
void BbTest::close_5A()
{
    addwidget4->close();
}
void BbTest::setDataStyle(QLabel *lab)
{
    QFont ft;
    ft.setPixelSize(15);

    lab->setFixedSize(90,27);
    lab->setFont(ft);
    lab->setAlignment(Qt::AlignCenter);

    lab->setStyleSheet("color:red;");
}
